package com.hongxun.design.utils.httputil;

import android.text.TextUtils;

import com.alibaba.fastjson.JSON;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.utils.DistanceUtil;
import com.hongxun.design.MyApp;
import com.hongxun.design.bean.CreateDistanceBean;
import com.hongxun.design.bean.CreateProjectBean;
import com.hongxun.design.bean.Exploration;
import com.hongxun.design.bean.PhotoEnvironmentalItemBean;
import com.hongxun.design.bean.SetPointInfItemBean;
import com.hongxun.design.bean.UserBean;
import com.hongxun.design.bean.photopassbean.PhotoPassIconBean;
import com.hongxun.design.constant.Constant;
import com.hongxun.design.mytools.MString;
import com.hongxun.design.mytools.MyLog;
import com.lidroid.xutils.http.RequestParams;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zerdoor_pc on 2016/5/19.
 */
public class PostParams {
    /**
     * 创建项目*
     */
    public static Map<String, Object> map = null;

    public static RequestParams CreateProject(List<CreateProjectBean> data) {
        map = new HashMap<>();
        RequestParams params = new RequestParams();
        params.addBodyParameter(MString.cost_center, MyApp.userInfo.getOrg_id());
        MyApp.createProject.setCost_center(MyApp.userInfo.getOrg_id());
        map.put(MString.cost_center, MyApp.userInfo.getOrg_id());
        for (CreateProjectBean bean : data) {
            String code = bean.getSendCode();
            if (code.equals(MString.project_name)) {
                MyApp.createProject.setProject_name(bean.getValue());
                params.addBodyParameter(code, bean.getValue());
                map.put(code, bean.getValue());
            } else if (code.equals(MString.project_type)) {
                MyApp.createProject.setProject_type(bean.getValue());
                params.addBodyParameter(code, bean.getValuecode());
//                map.put(code, bean.getValue());
                map.put(code, bean.getValuecode());
            } else if (code.equals(MString.address)) {
                if (bean.getValue().length() != 0 && bean.getLating() != null) {
                    double[] lating = bean.getLating();
                    if (lating.length < 3) {
                        double[] lating0 = new double[]{lating[0], lating[1], 0};
                        bean.setLating(lating0);
                    } else {
                        if (MString.erroralt.equals(lating[2] + "")) {
                            bean.getLating()[2] = 0;
                        }
                    }
                    if (bean.getValue().contains("纬度：") && bean.getValue().contains("经度：")) {
                    } else {
                        params.addBodyParameter(code, bean.getValue());
                        map.put(bean.getSendCode(), bean.getValue());
                    }
                    params.addBodyParameter(MString.lng, bean.getLating()[0] + "");
                    params.addBodyParameter(MString.lat, bean.getLating()[1] + "");
                    params.addBodyParameter(MString.alt, bean.getLating()[2] + "");

                    map.put(MString.lng, bean.getLating()[0] + "");
                    map.put(MString.lat, bean.getLating()[1] + "");
                    map.put(MString.alt, bean.getLating()[2] + "");

                    MyApp.createProject.setLng(bean.getLating()[0] + "");
                    MyApp.createProject.setLat(bean.getLating()[1] + "");
                } else {
                    if (MyApp.bdLocation != null) {
                        map.put(bean.getSendCode(), MyApp.bdLocation.getAddrStr());
                        map.put(MString.lng, MyApp.bdLocation.getLongitude() + "");
                        map.put(MString.lat, MyApp.bdLocation.getLatitude() + "");

                        params.addBodyParameter(code, MyApp.bdLocation.getAddrStr());
                        params.addBodyParameter(MString.lng, MyApp.bdLocation.getLongitude() + "");
                        params.addBodyParameter(MString.lat, MyApp.bdLocation.getLatitude() + "");
                        if (MString.erroralt.equals(Double.parseDouble(MyApp.bdLocation.getAltitude() + "") + "")) {
                            params.addBodyParameter(MString.alt, "0");
                            map.put(MString.alt, "0");
                        } else {
                            params.addBodyParameter(MString.alt, Double.parseDouble(MyApp.bdLocation.getAltitude() + "") + "");
                            map.put(MString.alt, Double.parseDouble(MyApp.bdLocation.getAltitude() + "") + "");
                        }
                        MyApp.createProject.setLng(MyApp.bdLocation.getLongitude() + "");
                        MyApp.createProject.setLat(MyApp.bdLocation.getLatitude() + "");
                    }
                }
            } else if (code.equals(MString.manager)) {
                params.addBodyParameter(code, bean.getValuecode());
                MyApp.createProject.setManager(bean.getValuecode());
                MyApp.createProject.setManager_name(bean.getValue());
                map.put(code, bean.getValue());
                map.put(code + "_id", bean.getValuecode());
            } else if (code.equals(MString.explorationer)) {
                params.addBodyParameter(code, bean.getValuecode());
                MyApp.createProject.setExplorationer(bean.getValuecode());
                MyApp.createProject.setExplorationer_name(bean.getValue());
                map.put(code, bean.getValue());
                map.put(code + "_id", bean.getValuecode());
            } else if (code.equals(MString.characters_remark)) {
                params.addBodyParameter(code, bean.getValue());
                map.put(code, bean.getValue());
            }
        }
        return params;
    }

    private static String getId(List<UserBean> beans) {
        if (beans == null || beans.size() == 0) return "";
        String s = "";
        for (UserBean bean : beans) {
            s += bean.getId() + ",";
        }

        return s.substring(0, s.length() - 1);
    }

    private static String getName(List<UserBean> beans) {
        if (beans == null || beans.size() == 0) return "";
        String s = "";
        for (UserBean bean : beans) {
            s += bean.getRealname() + ",";
        }

        return s.substring(0, s.length() - 1);
    }

    /**
     * 上传文件*
     */
    public static RequestParams File(File file, String type) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("file", file);
        params.addBodyParameter("type", type);
        MyLog.L(MString.Params + "file == " + file);
        MyLog.L(MString.Params + "file.length == " + file.length());
        MyLog.L(MString.Params + "type == " + type);
        return params;
    }

    /**
     * 删除踏勘点*
     */
    public static RequestParams delectExploration(String exploration_id) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("exploration_id", exploration_id);
        MyLog.L(MString.Params + "exploration_id = " + exploration_id);
        return params;
    }

    /**
     * 踏勘点位信息设置*
     */

    public static RequestParams setExploration(String stage_id, List<SetPointInfItemBean> data, List<Exploration> point) {
        BeforeExp = null;
        RequestParams params = new RequestParams();
        map = null;
        map = new HashMap<>();
        Map<String, String> jmap = new HashMap<>();


        String s = "";
        //  &stage_id=42&exploration_type=12&location_way=12&lpt_id=100001&lng=104.068089&lat=30.574254&alt=0&number=A01&pt={"name":"gggg","wiring_way":"11"}
        MyLog.L(MString.Params + "data=" + JSON.toJSONString(data));
        params.addBodyParameter("stage_id", stage_id);
        map.put("stage_id", stage_id);
        s += "&stage_id=" + stage_id;
        //定位类型
        if (MyApp.currExploration.getLocation_way().length() > 0) {
            params.addBodyParameter("location_way", MyApp.currExploration.getLocation_way());
            map.put("location_way", MyApp.currExploration.getLocation_way());
            MyApp.currparmsExploration.setLocation_way(MyApp.currExploration.getLocation_way());
            s += "&location_way=" + MyApp.currExploration.getLocation_way();
        }
        //踏勘类型//新建拆旧
        if (MyApp.currExploration.getPoint_type().length() > 0) {
            params.addBodyParameter("exploration_type", MyApp.currExploration.getPoint_type());
            map.put("exploration_type", MyApp.currExploration.getPoint_type());
            MyApp.currparmsExploration.setPoint_type(MyApp.currExploration.getPoint_type());
            s += "&exploration_type=" + MyApp.currExploration.getPoint_type();
        }
        params.addBodyParameter(MString.pt_id, MyApp.currExploration.getPt_id() + "");
        map.put(MString.pt_id, MyApp.currExploration.getPt_id() + "");
        s += "&" + MString.pt_id + "=" + MyApp.currExploration.getPt_id();
        MyApp.currparmsExploration.setPt_id(MyApp.currExploration.getPt_id());
        double lng = 0;
        double lat = 0;
        String before_exp = "";
        String wire_times = "", wire_model = "", wire_type = "", voltage_grade = "";
        for (SetPointInfItemBean bean : data) {
            if (bean.getNameCode() == null) {
                params.addBodyParameter("lng", bean.getLon() + "");
                map.put("lng", bean.getLon() + "");
                params.addBodyParameter("lat", bean.getLat() + "");
                map.put("lat", bean.getLat() + "");

                params.addBodyParameter(MString.g_exp_id, bean.getValueid());
                s += "&" + MString.g_exp_id + "=" + bean.getValueid();
                map.put(MString.g_exp_id, bean.getValueid() + "");
                if (bean.getAltitude() != null && bean.getAltitude().length() > 0) {
                    params.addBodyParameter("alt", bean.getAltitude() + "");
                    map.put("alt", bean.getAltitude() + "");
                    s += "&alt=" + bean.getAltitude();
                }
                lng = bean.getLon();
                lat = bean.getLat();
                s += "&lng=" + bean.getLon();
                s += "&lat=" + bean.getLat();

                // s += "&" + MString.distance + "=0";
                MyApp.currparmsExploration.setLng(bean.getLon() + "");
                MyApp.currparmsExploration.setLat(bean.getLat() + "");
                MyApp.currparmsExploration.setAlt(bean.getAltitude() + "");
            } else {
                if (bean.getNameCode().equals(MString.number) || bean.getNameCode().equals(MString.before_exp) || bean.getNameCode().equals(MString.voltage_grade) || bean.getNameCode().equals(MString.corner)) {
                    if (!TextUtils.isEmpty(bean.getValueCode())) {
                        if (bean.getNameCode().equals(MString.before_exp)) {
                            if (bean.getValueCode().length() != 0) {
                                MyApp.currparmsExploration.setBefore_exp(bean.getValueCode());
                                params.addBodyParameter(bean.getNameCode(), bean.getValueCode() + "");
                                map.put(bean.getNameCode(), bean.getValueCode() + "");
                                before_exp = bean.getValueCode();
                                s += "&" + bean.getNameCode() + "=" + bean.getValueCode();
                            }
                        } else {
                            if (bean.getNameCode().equals(MString.number)) {
                                MyApp.currparmsExploration.setNumber(bean.getValueCode());
                            } else if (bean.getNameCode().equals(MString.voltage_grade)) {
                                MyApp.currparmsExploration.setVoltage_grade(bean.getValueCode());
                                voltage_grade = bean.getValueCode();
                            } else if (bean.getNameCode().equals(MString.corner)) {
                                MyApp.currparmsExploration.setCorner(bean.getValueCode());
                            }
                            params.addBodyParameter(bean.getNameCode(), bean.getValueCode() + "");
                            map.put(bean.getNameCode(), bean.getValueCode() + "");
                            s += "&" + bean.getNameCode() + "=" + bean.getValueCode();
                        }
                    } else {
                        if (bean.getNameCode().equals(MString.corner) || bean.getNameCode().equals(MString.before_exp)) {
                            // params.addBodyParameter(bean.getNameCode(), "");
                            // s += "&" + bean.getNameCode() + "=";
                        } else {
                            params.addBodyParameter(bean.getNameCode(), "0");
                            map.put(bean.getNameCode(), "0");
                            s += "&" + bean.getNameCode() + "=0";
                        }

                    }

                } else {
                    if (MString.is_common.equals(bean.getNameCode())) {
//                        if (MyApp.currExploration.getApapterStates() == 1) {
//                            jmap.put(MString.voltage_type, "11");
//                        } else if (MyApp.currExploration.getApapterStates() == 2) {
//                            jmap.put(MString.voltage_type, "12");
//                        }

                    }
                    if (!TextUtils.isEmpty(bean.getValue())) {
                        if (bean.getNameCode().equals(MString.user_name)) {
//                            params.addBodyParameter(MString.all_user, bean.getValueCode() + "");
//                            params.addBodyParameter(bean.getNameCode(), bean.getValue() + "");
//                            s += "&" + MString.all_user + "=" + bean.getValueCode();
//                            s += "&" + bean.getNameCode() + "=" + bean.getValue();
                            jmap.put(MString.all_user, bean.getValueCode() + "");
                            jmap.put(bean.getNameCode(), bean.getValue() + "");
                            s += "&" + bean.getNameCode() + "=" + bean.getValue();
                        } else {
                            if (bean.getNameCode().equals(MString.wire_times)) {
                                wire_times = bean.getValueCode();
                                MyLog.L(MString.Params + "wire_times=" + wire_times);
                            } else if (bean.getNameCode().equals(MString.wire_model)) {
                                wire_model = bean.getValueCode();
                                MyLog.L(MString.Params + "wire_model=" + wire_model);
                            } else if (bean.getNameCode().equals(MString.wire_type)) {
                                wire_type = bean.getValueCode();
                                MyLog.L(MString.Params + "wire_type=" + wire_type);
                            } else {

                                jmap.put(bean.getNameCode(), bean.getValueCode());
                                s += "&" + bean.getNameCode() + "=" + bean.getValueCode();
                            }
                        }
                    }

                }
            }
        }

        String head = "high_";
        if (voltage_grade.equals(MString.highVoltage)) {
            head = "high_";

        } else {
            head = "low_";
        }

        jmap.put(head + MString.wire_times, wire_times);
        jmap.put(head + MString.wire_model, wire_model);
        jmap.put(head + MString.wire_type, wire_type);
        s += "&" + head + MString.wire_times + "=" + wire_times;
        s += "&" + head + MString.wire_model + "=" + wire_model;
        s += "&" + head + MString.wire_type + "=" + wire_type;
        if (MyApp.currExploration.getPt_id().equals(MString.Transformer)) {
            String id = MString.getValueId(MyApp.currExploration.getExploration_id(), MyApp.currExploration.getUuid());
            MyApp.currparmsExploration.setExplor_id(id);
            map.put(MString.explor_id, id);
        }

        if (before_exp.length() == 0) {
            MyApp.currparmsExploration.setDistance("");
            MyApp.currparmsExploration.setBefore_lat("");
            MyApp.currparmsExploration.setBefore_lng("");
            map.put(MString.before_number, "");
            map.put(MString.distance, "");
            map.put(MString.before_exp, null);
            map.put(MString.before_lat, "");
            map.put(MString.before_lng, "");
        } else {
            for (Exploration e : point) {
                if ((e.exploration_id != null && !e.exploration_id.equals(MString.code_null) && e.exploration_id.equals(before_exp)) || (e.getUuid().length() > 0 && e.getUuid().equals(before_exp))) {
                    try {
                        if (!(lat == 0 || lng == 0) && !(Double.parseDouble(e.lat) == 0 || Double.parseDouble(e.lng) == 0)) {
                            String distence = DistanceUtil.getDistance(new LatLng(lat, lng), new LatLng(Double.parseDouble(e.lat), Double.parseDouble(e.lng))) + "";
                            params.addBodyParameter(MString.distance, distence);
                            map.put(MString.distance, distence);
                            s += "&" + MString.distance + "=" + DistanceUtil.getDistance(new LatLng(lat, lng), new LatLng(Double.parseDouble(e.lat), Double.parseDouble(e.lng)));
                            double distance = DistanceUtil.getDistance(new LatLng(lat, lng), new LatLng(Double.parseDouble(e.lat), Double.parseDouble(e.lng)));
                            MyApp.currparmsExploration.setDistance(distance + "");
                            MyApp.currparmsExploration.setBefore_exp(MString.getValueId(e.getExploration_id(), e.getUuid()));
                            map.put(MString.before_number, e.getNumber());
                            map.put(MString.distance, distance);
                            map.put(MString.before_lat, e.lat);
                            map.put(MString.before_lng, e.lng);
                            MyApp.currparmsExploration.setBefore_lat(e.lat);
                            MyApp.currparmsExploration.setBefore_lng(e.lng);
                            if (e.getPt_id().equals(MString.Transformer)) {
                                String id = MString.getValueId(e.getExploration_id(), e.getUuid());
                                MyApp.currparmsExploration.setExplor_id(id);
                                map.put(MString.explor_id, id);
                            } else if (e.getExplor_id() != null && e.getExplor_id().length() > 0 && !e.getExplor_id().equals(MString.code_zero)) {
                                MyApp.currparmsExploration.setExplor_id(e.getExplor_id());
                                map.put(MString.explor_id, e.getExplor_id());
                            } else {
                                MyApp.currparmsExploration.setExplor_id(e.getExplor_id());
                                map.put(MString.explor_id, e.getExplor_id());
                            }
                            BeforeExp = e;
                        }
                    } catch (Exception e1) {
                        MyLog.L(MString.SUCCESSED + "  e1==" + e1.toString());
                    }
                    break;
                }
            }
        }


        params.addBodyParameter("pt", JSON.toJSONString(jmap));
        map.put("pt", JSON.toJSONString(jmap));
        s += "&pt=" + JSON.toJSONString(jmap);
        MyLog.L(MString.Params + "end=" + s);
        MyLog.L(MString.Params + "jsonMap=" + JSON.toJSONString(map));//请求数据格式
        //MyApp.currExploration.setJson(JSON.toJSONString(jsonMap));//存储请求字段
        return params;
    }

    public static Exploration BeforeExp;

    /**
     * 保存踏勘点位信息设置*
     */
    public static RequestParams updateExploration(List<SetPointInfItemBean> data, String pt_id, List<Exploration> point) {
        RequestParams params = new RequestParams();
        Map<String, Object> jsonMap = new HashMap<>();
        BeforeExp = null;
        String s = "";
        MyLog.L(MString.Params + "data=" + JSON.toJSONString(data));
        params.addBodyParameter("pt_id", pt_id);
        MyApp.currparmsExploration.setPt_id(pt_id);
        jsonMap.put("pt_id", pt_id);
        s += "&" + MString.pt_id + "=" + pt_id;
        params.addBodyParameter("exploration_id", MyApp.currExploration.getExploration_id());
        MyApp.currparmsExploration.setExploration_id(MyApp.currExploration.getExploration_id());
        jsonMap.put("exploration_id", MyApp.currExploration.getExploration_id());
        s += "&exploration_id=" + MyApp.currExploration.getExploration_id();
        //定位类型
        if (MyApp.currExploration.getLocation_way().length() > 0) {
            params.addBodyParameter("location_way", MyApp.currExploration.getLocation_way());
            jsonMap.put("location_way", MyApp.currExploration.getLocation_way());
            MyApp.currparmsExploration.setLocation_way(MyApp.currExploration.getLocation_way());
            s += "&location_way=" + MyApp.currExploration.getLocation_way();
        }
        //踏勘类型//新建拆旧
        if (MyApp.currExploration.getPoint_type().length() > 0) {
            params.addBodyParameter("exploration_type", MyApp.currExploration.getPoint_type());
            jsonMap.put("exploration_type", MyApp.currExploration.getPoint_type());
            MyApp.currparmsExploration.setPoint_type(MyApp.currExploration.getPoint_type());
            s += "&exploration_type=" + MyApp.currExploration.getPoint_type();
        }
        double lng = 0;
        double lat = 0;
        String before_exp = "";
        String wire_times = "", wire_model = "", wire_type = "", voltage_grade = "";
        Map<String, String> map = new HashMap<>();
        for (SetPointInfItemBean bean : data) {
            if (bean.getNameCode() == null) {
                params.addBodyParameter("lng", bean.getLon() + "");
                params.addBodyParameter("lat", bean.getLat() + "");

                params.addBodyParameter(MString.g_exp_id, bean.getValueid());
                s += "&" + MString.g_exp_id + "=" + bean.getValueid();
                jsonMap.put(MString.g_exp_id, bean.getValueid() + "");
                jsonMap.put("lng", bean.getLon() + "");
                jsonMap.put("lat", bean.getLat() + "");
                if (bean.getAltitude() != null && bean.getAltitude().length() > 0) {
                    params.addBodyParameter("alt", bean.getAltitude() + "");
                    jsonMap.put("alt", bean.getAltitude() + "");
                    s += "&alt=" + bean.getAltitude();
                }
                lng = bean.getLon();
                lat = bean.getLat();
                s += "&lng=" + bean.getLon();
                s += "&lat=" + bean.getLat();
                MyApp.currparmsExploration.setLng(bean.getLon() + "");
                MyApp.currparmsExploration.setLat(bean.getLat() + "");
                MyApp.currparmsExploration.setAlt(bean.getAltitude() + "");
            } else {
                if (bean.getNameCode().equals(MString.number) || bean.getNameCode().equals(MString.before_exp) || bean.getNameCode().equals(MString.voltage_grade) || bean.getNameCode().equals(MString.corner)) {
                    if (bean.getValueCode().length() != 0) {
                        if (bean.getNameCode().equals(MString.before_exp)) {
                            if (bean.getValueCode().length() != 0) {
                                MyApp.currparmsExploration.setBefore_exp(bean.getValueCode());
                                params.addBodyParameter(bean.getNameCode(), bean.getValueCode() + "");
                                jsonMap.put(bean.getNameCode(), bean.getValueCode() + "");
                                before_exp = bean.getValueCode();
                                s += "&" + bean.getNameCode() + "=" + bean.getValueCode();
                            }

                        } else {
                            params.addBodyParameter(bean.getNameCode(), bean.getValueCode() + "");
                            jsonMap.put(bean.getNameCode(), bean.getValueCode() + "");
                            s += "&" + bean.getNameCode() + "=" + bean.getValueCode();
                        }
                        if (MString.voltage_grade.equals(bean.getNameCode())) {
                            voltage_grade = bean.getValueCode();
                            MyApp.currparmsExploration.setVoltage_grade(bean.getValueCode());
                        }

                    } else {
                        if (bean.getNameCode().equals(MString.corner) || bean.getNameCode().equals(MString.before_exp)) {
                            //params.addBodyParameter(bean.getNameCode(), "");
                            //s += "&" + bean.getNameCode() + "=" ;
                        } else {
//                            params.addBodyParameter(bean.getNameCode(), "0");
//                            jsonMap.put(bean.getNameCode(), "0");
//                            s += "&" + bean.getNameCode() + "=0";
                        }

                    }
                } else {
                    if (MString.is_common.equals(bean.getNameCode())) {
//                        if (MyApp.currExploration.getApapterStates() == 1) {
//                            map.put(MString.voltage_type, "11");
//                        } else if (MyApp.currExploration.getApapterStates() == 2) {
//                            map.put(MString.voltage_type, "12");
//                        }
                        //map.put(MString.g_exp_id, bean.getValueid());

                    }
                    if (bean.getValue() != null) {
                        if (bean.getNameCode().equals(MString.user_name)) {
//                            params.addBodyParameter(MString.all_user, bean.getValueCode() + "");
//                            params.addBodyParameter(bean.getNameCode(), bean.getValue() + "");
//                            s += "&" + MString.all_user + "=" + bean.getValueCode();
//                            s += "&" + bean.getNameCode() + "=" + bean.getValue();
                            map.put(MString.all_user, bean.getValueCode() + "");
                            map.put(bean.getNameCode(), bean.getValue() + "");
                        } else {

                            if (bean.getNameCode().equals(MString.wire_times)) {
                                wire_times = bean.getValueCode();
                                MyLog.L(MString.Params + "wire_times=" + wire_times);
                            } else if (bean.getNameCode().equals(MString.wire_model)) {
                                wire_model = bean.getValueCode();
                                MyLog.L(MString.Params + "wire_model=" + wire_model);
                            } else if (bean.getNameCode().equals(MString.wire_type)) {
                                wire_type = bean.getValueCode();
                                MyLog.L(MString.Params + "wire_type=" + wire_type);
                            } else {

                                map.put(bean.getNameCode(), bean.getValueCode());
                                s += "&" + bean.getNameCode() + "=" + bean.getValueCode();
                            }
                            //  map.put(bean.getNameCode(), bean.getValueCode());
                        }
                    } else if (bean.getValueCode() != null) {
                        if (bean.getNameCode().equals(MString.user_name)) {
//                            params.addBodyParameter(MString.all_user, bean.getValueCode() + "");
//                            params.addBodyParameter(bean.getNameCode(), bean.getValue() + "");
//                            s += "&" + MString.all_user + "=" + bean.getValueCode();
//                            s += "&" + bean.getNameCode() + "=" + bean.getValue();
                            map.put(MString.all_user, bean.getValueCode() + "");
                        } else {

                            if (bean.getNameCode().equals(MString.wire_times)) {
                                wire_times = bean.getValueCode();
                                MyLog.L(MString.Params + "wire_times=" + wire_times);
                            } else if (bean.getNameCode().equals(MString.wire_model)) {
                                wire_model = bean.getValueCode();
                                MyLog.L(MString.Params + "wire_model=" + wire_model);
                            } else if (bean.getNameCode().equals(MString.wire_type)) {
                                wire_type = bean.getValueCode();
                                MyLog.L(MString.Params + "wire_type=" + wire_type);
                            } else {
                                map.put(bean.getNameCode(), bean.getValueCode());
                                s += "&" + bean.getNameCode() + "=" + bean.getValueCode();
                            }
                            //  map.put(bean.getNameCode(), bean.getValueCode());
                        }
                    }
                }
            }
        }


        String head = "high_";
        if (voltage_grade.equals(MString.highVoltage)) {
            head = "high_";

        } else {
            head = "low_";
        }

        map.put(head + MString.wire_times, wire_times);
        map.put(head + MString.wire_model, wire_model);
        map.put(head + MString.wire_type, wire_type);
        s += "&" + head + MString.wire_times + "=" + wire_times;
        s += "&" + head + MString.wire_model + "=" + wire_model;
        s += "&" + head + MString.wire_type + "=" + wire_type;
        if (before_exp.length() == 0) {
            MyApp.currparmsExploration.setDistance("");
            MyApp.currparmsExploration.setBefore_lat("");
            MyApp.currparmsExploration.setBefore_lng("");
        } else {
            for (Exploration e : point) {
                if ((e.exploration_id != null && !e.exploration_id.equals(MString.code_null) && e.exploration_id.equals(before_exp)) || (e.getUuid().length() > 0 && e.getUuid().equals(before_exp))) {
                    params.addBodyParameter(MString.distance, DistanceUtil.getDistance(new LatLng(lat, lng), new LatLng(Double.parseDouble(e.lat), Double.parseDouble(e.lng))) + "");
                    jsonMap.put(MString.distance, DistanceUtil.getDistance(new LatLng(lat, lng), new LatLng(Double.parseDouble(e.lat), Double.parseDouble(e.lng))) + "");
                    s += "&" + MString.distance + "=" + DistanceUtil.getDistance(new LatLng(lat, lng), new LatLng(Double.parseDouble(e.lat), Double.parseDouble(e.lng)));
                    double distance = DistanceUtil.getDistance(new LatLng(lat, lng), new LatLng(Double.parseDouble(e.lat), Double.parseDouble(e.lng)));
                    MyLog.L(MString.SUCCESSED + "ParamsDistance========" + distance);
                    MyApp.currparmsExploration.setDistance(distance + "");
                    MyApp.currparmsExploration.setBefore_exp(MString.getValueId(e.getExploration_id(), e.getUuid()));
                    MyApp.currparmsExploration.setBefore_lat(e.lat);
                    MyApp.currparmsExploration.setBefore_lng(e.lng);
                    BeforeExp = e;
                    break;
                }
            }
        }

        params.addBodyParameter("pt", JSON.toJSONString(map));
        jsonMap.put("pt", JSON.toJSONString(map));
        s += "&pt=" + JSON.toJSONString(map);
        MyLog.L(MString.Params + "end=" + s);

        MyLog.L(MString.Params + "jsonMap=" + JSON.toJSONString(jsonMap));//请求数据格式
        return params;
    }

    /**
     * 踏勘点位信息继续设置*
     */
    public static RequestParams setConExploration(List<SetPointInfItemBean> data) {
        RequestParams params = new RequestParams();
        map = new HashMap<>();

        params.addBodyParameter("exploration_id", MyApp.currExploration.getExploration_id());
        map.put("exploration_id", MyApp.currExploration.getExploration_id());
        MyApp.currparmsExploration.setExploration_id(MyApp.currExploration.getExploration_id());
        if (MyApp.currExploration.getId().length() != 0) {
            params.addBodyParameter("id", MyApp.currExploration.getId());
            map.put("id", MyApp.currExploration.getId());
        }

        params.addBodyParameter("stage_id", MyApp.currProject.getStage_id());
        map.put("stage_id", MyApp.currProject.getStage_id());

        //定位类型
        if (MyApp.currExploration.getLocation_way().length() > 0) {
            params.addBodyParameter("location_way", MyApp.currExploration.getLocation_way());
            map.put("location_way", MyApp.currExploration.getLocation_way());
            MyApp.currparmsExploration.setLocation_way(MyApp.currExploration.getLocation_way());
        }
        //踏勘类型//新建拆旧
        if (MyApp.currExploration.getPoint_type().length() > 0) {
            params.addBodyParameter("exploration_type", MyApp.currExploration.getPoint_type());
            map.put("exploration_type", MyApp.currExploration.getPoint_type());
            MyApp.currparmsExploration.setPoint_type(MyApp.currExploration.getPoint_type());
        }

        if (MyApp.currExploration.getPt_id().length() > 0) {
            params.addBodyParameter(MString.pt_id, MyApp.currExploration.getPt_id() + "");
            map.put(MString.pt_id, MyApp.currExploration.getPt_id() + "");
            MyApp.currparmsExploration.setPt_id(MyApp.currExploration.getPt_id());
        }
        String wire_times = "", wire_model = "", wire_type = "", voltage_grade = "";
        for (SetPointInfItemBean bean : data) {
            if (bean.getNameCode() == null && bean.getAltitude() != null) {
                params.addBodyParameter("lng", bean.getLon() + "");
                params.addBodyParameter("lat", bean.getLat() + "");
                params.addBodyParameter(MString.g_exp_id, bean.getValueid());
                map.put(MString.g_exp_id, bean.getValueid() + "");
                map.put("lng", bean.getLon() + "");
                map.put("lat", bean.getLat() + "");
                if (bean.getAltitude() != null && bean.getAltitude().length() > 0) {
                    params.addBodyParameter("alt", bean.getAltitude() + "");
                    map.put("alt", bean.getAltitude() + "");
                }
            } else if (bean.getNameCode() != null) {
                if (bean.getNameCode().equals(MString.number) || bean.getNameCode().equals(MString.before_exp)
                        || bean.getNameCode().equals(MString.corner)) {
                    {
                        if (bean.getNameCode().equals(MString.corner)) {
                            if (null == bean.getValueCode() || bean.getValueCode().length() == 0) {
                            } else {
                                params.addBodyParameter(bean.getNameCode(), bean.getValueCode() + "");
                                map.put(bean.getNameCode(), bean.getValueCode() + "");
                            }
                        } else if (bean.getValue().length() != 0) {
                            params.addBodyParameter(bean.getNameCode(), bean.getValueCode() + "");
                            map.put(bean.getNameCode(), bean.getValueCode() + "");
                        } else {
                            if (!(bean.getNameCode().equals(MString.corner) || bean.getNameCode().equals(MString.before_exp))) {
                                params.addBodyParameter(bean.getNameCode(), "0");
                                map.put(bean.getNameCode(), "0");
                            }
                        }
                    }
                } else {
                    if (MString.voltage_grade.equals(bean.getNameCode())) {
                        voltage_grade = bean.getValueCode();
                    }
                    if (!TextUtils.isEmpty(bean.getValue())) {
                        if (bean.getNameCode().equals(MString.user_name)) {
                            params.addBodyParameter(MString.all_user, bean.getValueCode() + "");
                            params.addBodyParameter(bean.getNameCode(), bean.getValue() + "");
                            map.put(MString.all_user, bean.getValueCode() + "");
                            map.put(bean.getNameCode(), bean.getValue() + "");
                        } else {
                            if (bean.getNameCode().equals(MString.codeset_id)) {
                                params.addBodyParameter(MString.codeset_name, bean.getValue());
                                map.put(MString.codeset_name, bean.getValue());
                            }
                            if (bean.getNameCode().equals(MString.wire_times)) {
                                wire_times = bean.getValueCode();
                            } else if (bean.getNameCode().equals(MString.wire_model)) {
                                wire_model = bean.getValueCode();
                            } else if (bean.getNameCode().equals(MString.wire_type)) {
                                wire_type = bean.getValueCode();
                            } else {
                                params.addBodyParameter(bean.getNameCode(), bean.getValueCode());
                                map.put(bean.getNameCode(), bean.getValueCode());
                            }
                        }

                    } else if (!TextUtils.isEmpty(bean.getValueCode()) && !bean.getNameCode().equals(MString.user_name)) {
                        if (bean.getNameCode().equals(MString.wire_times)) {
                            wire_times = bean.getValueCode();
                        } else if (bean.getNameCode().equals(MString.wire_model)) {
                            wire_model = bean.getValueCode();
                        } else if (bean.getNameCode().equals(MString.wire_type)) {
                            wire_type = bean.getValueCode();
                        } else {
                            params.addBodyParameter(bean.getNameCode(), bean.getValueCode());
                            map.put(bean.getNameCode(), bean.getValueCode());
                        }
                    }
                }
            }
        }


        String head = "high_";
        if (voltage_grade.equals(MString.highVoltage)) {
            head = "high_";
        } else {
            head = "low_";
        }
        params.addBodyParameter(head + MString.wire_times, wire_times);
        params.addBodyParameter(head + MString.wire_model, wire_model);
        params.addBodyParameter(head + MString.wire_type, wire_type);

        map.put(head + MString.wire_times, wire_times);
        map.put(head + MString.wire_model, wire_model);
        map.put(head + MString.wire_type, wire_type);

        return params;
    }

    /**
     * 保存踏勘照片*
     */
    public static RequestParams SaveExpPhoto(File file, String type, String exploration_id, int photo_type) {
        RequestParams params = new RequestParams();
        String s = "";
        params.addBodyParameter("file", file);
        s += "&file=" + file;
        params.addBodyParameter("type", type);
        s += "&type=" + type;
        params.addBodyParameter("exploration_id", exploration_id);
        s += "&exploration_id=" + exploration_id;
        params.addBodyParameter("photo_type", photo_type + "");
        s += "&photo_type=" + photo_type;
        MyLog.L(MString.SUCCESSED + s);
        return params;
    }

    /**
     * 删除踏勘照片*
     */
    public static RequestParams DelExpPhoto(String photo_id) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("photo_id", photo_id);
        return params;
    }

    /**
     * 保存踏勘环境信息*
     */
    public static RequestParams SaveEnv(Object o) {
        RequestParams params = new RequestParams();
        map = null;
        map = new HashMap<>();
        String s = "";
        params.addBodyParameter("exploration_id", MyApp.currExploration.getExploration_id());
        map.put("exploration_id", MyApp.currExploration.getExploration_id());
        s = "&exploration_id=" + MyApp.currExploration.getExploration_id();
        List<PhotoEnvironmentalItemBean> beans = (List<PhotoEnvironmentalItemBean>) o;
        for (PhotoEnvironmentalItemBean bean : beans) {
            if (bean.getTitlecode().equals(MString.voice_remark)) {
                if (bean.getPath().length() > 0) {
                    params.addBodyParameter(bean.getTitlecode(), bean.getPath());
                    map.put(bean.getTitlecode(), bean.getPath());
                    s += "&" + bean.getTitlecode() + "=" + bean.getPath();
                }
            } else {
                if (bean.getType() == Constant.ChoiceItem && bean.getValuecode() != null && bean.getValuecode().length() > 0) {
                    params.addBodyParameter(bean.getTitlecode(), bean.getValuecode());
                    map.put(bean.getTitlecode(), bean.getValuecode());
                    s += "&" + bean.getTitlecode() + "=" + bean.getValuecode();
                }
                if (bean.getType() == Constant.EdItem && bean.getValue() != null && bean.getValue().length() > 0) {
                    params.addBodyParameter(bean.getTitlecode(), bean.getValue());
                    map.put(bean.getTitlecode(), bean.getValue());
                    s += "&" + bean.getTitlecode() + "=" + bean.getValue();
                }
                if (bean.getTitlecode().equals(MString.characters_remark) && bean.getValue() != null && bean.getValue().length() != 0) {
                    params.addBodyParameter(bean.getTitlecode(), bean.getValue());
                    map.put(bean.getTitlecode(), bean.getValue());
                    s += "&" + bean.getTitlecode() + "=" + bean.getValue();
                }
            }
        }

        MyLog.L(MString.Params + "s==" + s);
//        params.addBodyParameter("traffic", traffic);
//        params.addBodyParameter("width", width);
//        params.addBodyParameter("haul_distance", haul_distance);
//        params.addBodyParameter("voice_remark", voice_remark);

        return params;
    }

    /**
     * 关联通道特征信息*
     */
    public static RequestParams CorrChannelFeature(String exploration_id, String after_exp) {
        RequestParams params = new RequestParams();
        String s = "";
        params.addBodyParameter("exploration_id", exploration_id);
        params.addBodyParameter("after_exp", after_exp);
        s += "exploration_id=" + exploration_id + "&after_exp=" + after_exp;
        MyLog.L(MString.Params + s);
        return params;
    }

    /**
     * 新增通道特征信息*
     */
    public static RequestParams AddChannelFeature(String pt_id, String after_exp, String distance) {
        RequestParams params = new RequestParams();
        String s = "";
        params.addBodyParameter("pt_id", pt_id);
        params.addBodyParameter("after_exp", after_exp);
        params.addBodyParameter("distance", distance);
        s += "pt_id=" + pt_id + "&after_exp=" + after_exp + "&distance=" + distance;
        MyLog.L(MString.Params + s);
        return params;
    }


    /**
     * 修改通道特征信息*
     */
    public static RequestParams UpChannelFeature(String channel_id, Object data) {
        RequestParams params = new RequestParams();
        map = null;
        map = new HashMap<>();
        String s = "";
        params.addBodyParameter("channel_id", channel_id);
        map.put("channel_id", channel_id);
        s += "channel_id=" + channel_id;
        List<PhotoPassIconBean> beans = (List<PhotoPassIconBean>) data;
        for (PhotoPassIconBean b : beans) {
            if (b.getType() == Constant.ChoiceItem && b.getValuecode() != null && b.getValuecode().length() != 0) {
                params.addBodyParameter(b.getTitleCode(), b.getValuecode());
                map.put(b.getTitleCode(), b.getValuecode());
                s += "&" + b.getTitleCode() + "=" + b.getValuecode();
            } else if (b.getType() == Constant.EdItem && b.getValue() != null && b.getValue().length() != 0) {
                params.addBodyParameter(b.getTitleCode(), b.getValue());
                map.put(b.getTitleCode(), b.getValue());
                s += "&" + b.getTitleCode() + "=" + b.getValue();
            }
        }
        MyLog.L(MString.Params + "s==" + s);
        return params;
    }

    /**
     * 删除通道特征信息*
     */
    public static RequestParams DelChannelFeature(String channel_id) {
        RequestParams params = new RequestParams();
        map = null;
        map = new HashMap<>();
        params.addBodyParameter("channel_id", channel_id);
        map.put("channel_id", channel_id);
        return params;
    }

    /**
     * 删除踏勘典设材料*
     */
    public static RequestParams DelExpMaterial(String id) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("id", id);
        MyLog.L(MString.Params + "id=" + id);
        return params;
    }

    /**
     * 修改踏勘典设材料数量*
     */
    public static RequestParams UpExpMaterial(String id, String obj_id, String num, String use_type) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("matId", id);
        params.addBodyParameter("obj_id", obj_id);
        params.addBodyParameter("num", num);
        params.addBodyParameter("use_type", use_type);
        MyLog.L(MString.Params + "?matId=" + id + "&obj_id=" + obj_id + "&use_type=" + use_type + "&num=" + num);

        return params;
    }

    /**
     * 踏勘典设导入材料*
     */
    public static RequestParams ImpExpMaterial(String material_id) {
        RequestParams params = new RequestParams();
        String s = "";
        params.addBodyParameter("material_id", material_id);
        params.addBodyParameter("exploration_id", MyApp.currExploration.getExploration_id());
        s += "material_id=" + material_id;
        s += "exploration_id=" + MyApp.currExploration.getExploration_id();
        MyLog.L(MString.Params + "s=" + s);

        return params;
    }

    /**
     * 踏勘典设导入模块*
     */
    public static RequestParams ImpExpModule(String module_id) {
        RequestParams params = new RequestParams();
        String s = "";
        params.addBodyParameter("module_id", module_id);
        params.addBodyParameter("exploration_id", MyApp.currExploration.getExploration_id());
        s += "module_id=" + module_id;
        s += "exploration_id=" + MyApp.currExploration.getExploration_id();
        MyLog.L(MString.Params + "s=" + s);

        return params;
    }

    /**
     * 保存踏勘典设方案*
     */
    public static RequestParams SaveExpCodeset(String codeset_id, String exploration_id) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("codeset_id", codeset_id);
        params.addBodyParameter("exploration_id", MyApp.currExploration.getExploration_id());
        MyLog.L(MString.Params + "codeset_id=" + codeset_id);
        MyLog.L(MString.Params + "exploration_id=" + MyApp.currExploration.getExploration_id());
        return params;
    }


    /**
     * 注册*
     */
    public static RequestParams regedit(List<CreateDistanceBean> beans) {
        RequestParams params = new RequestParams();
        String s = "";
        params.addBodyParameter("key", MString.RegisterKey);
        s += "&key=" + MString.RegisterKey;
        for (CreateDistanceBean b : beans) {
            params.addBodyParameter(b.getTitleCode(), b.getValue());
            s += "&" + b.getTitleCode() + "=" + b.getValue();
        }
        MyLog.L(MString.SUCCESSED + "s=" + s);
        return params;
    }


    /**
     * 项目典设选择材料*
     */
    public static RequestParams ImpProMaterial(String material_id, String codsetid) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("material_id", material_id);
        params.addBodyParameter("codeset_id", codsetid);
        return params;
    }

    /**
     * new项目材料数量
     */
    public static RequestParams GetProItemCount(String versionid) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("versionid", versionid);
        return params;
    }

    /**
     * 项目典设选择材料*
     */
    public static RequestParams ImpProModelToDS(String model_id, String codsetid) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("module_id", model_id);
        params.addBodyParameter("codeset_id", codsetid);
        return params;
    }

    public static RequestParams getProRec(String stageid, String lasttime) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("stageid", stageid);
        params.addBodyParameter("lasttime", lasttime);
        return params;
    }

    public static RequestParams getProBase(Object... obj) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("orgid", String.valueOf(obj[0]));
        return params;
    }

    public static RequestParams getProItem(Object... obj) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("stateid", String.valueOf(obj[0]));
        return params;
    }
    public static RequestParams getBjList(Object... obj){
        RequestParams params=new RequestParams();
        params.addBodyParameter("bx_id",String.valueOf(obj[0]));
        params.addBodyParameter("bjList",String.valueOf(obj[1]));
        return params;
    }


}
